package cn.yuanqiao.web.controller.archive.collection.appManager;


import cn.yuanqiao.archive.collection.appManager.domain.YqDataTree;
import cn.yuanqiao.archive.collection.appManager.service.IYqDataTreeService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.web.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资料树表现层
 *
 * @ProjectName: ruoyi-modules-system
 * @Package: cn.yuanqiao.web.controller.archive.appManager
 * @ClassName: YqDataTreeController
 * @Author: lenovo
 * @Description: hbWang
 * @Date: 2023/7/28 11:36
 * @Version: 1.0
 */
@RestController
@RequestMapping("/archive/collection/data/tree")
public class YqDataTreeController extends BaseController {
    @Autowired
    private IYqDataTreeService yqDataTreeService;

    /**
     * 查询资料树列表
     */
    //@PreAuthorize("@ss.hasPermi('archive:dataTree:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqDataTree yqDataTree) {

        List<YqDataTree> list = yqDataTreeService.selectYqDataTreeList(yqDataTree);
        return getDataTable(list);
    }


    /**
     * 获取资料树详细信息
     */

    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID) {
        return success(yqDataTreeService.selectYqDataTreeByID(ID));
    }

    /**
     * 新增资料树
     */
    // @PreAuthorize("@ss.hasPermi('archive:dataTree:add')")
    @Log(title = "资料树", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqDataTree yqDataTree) {
        return toAjax(yqDataTreeService.insertYqDataTree(yqDataTree));
    }

    /**
     * 修改资料树
     */
    //@PreAuthorize("@ss.hasPermi('archive:dataTree:edit')")
    @Log(title = "资料树", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqDataTree yqDataTree) {
        return toAjax(yqDataTreeService.updateYqDataTree(yqDataTree));
    }

    /**
     * 删除资料树
     */
    //@PreAuthorize("@ss.hasPermi('archive:dataTree:remove')")
    @Log(title = "资料树", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") String id) {
        return toAjax(yqDataTreeService.deleteYqDataTreeByID(id));
    }
}
